import 'package:number_spark_flutter/style/ns_style.dart';
import 'package:number_spark_flutter/widgets/brick/ns_brick.dart';
import 'package:flutter/material.dart';
import 'package:flutter_picker/flutter_picker.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class NSPickerUtil {
  static showPickerDateTime(BuildContext context, int type, PickerConfirmCallback confirmCallback,
      {PickerSelectedCallback? selectedCallback, DateTime? chooseDateTime, DateTime? maxDateTime, DateTime? minDateTime}) {
    Picker picker = Picker(
        height: 200.w,
        itemExtent: 40.w,
        backgroundColor: Colors.transparent,
        headerDecoration: const BoxDecoration(border: Border(bottom: BorderSide(color: Colors.black12, width: 0.5))),
        adapter: DateTimePickerAdapter(
          type: type,
          isNumberMonth: true,
          strAMPM: const ["am", "pm"],
          yearSuffix: "",
          monthSuffix: "",
          daySuffix: "",
          value: chooseDateTime ?? DateTime.now(),
          minValue: minDateTime,
          maxValue: maxDateTime,
          minuteInterval: 1,
          minHour: 0,
          maxHour: 23,
          // twoDigitYear: true,
        ),
        title: Text("", style: TextStyle(fontSize: 15.sp)),
        textAlign: TextAlign.right,
        confirmText: 'Confirm',
        cancelText: 'Cancel',
        confirmTextStyle: TextStyle(color: kAppColor('#000000'), fontSize: 14.sp, fontWeight: FontWeight.bold),
        cancelTextStyle: TextStyle(color: kAppTextColor, fontSize: 14.sp, fontWeight: FontWeight.bold),
        textStyle: TextStyle(color: kAppColor('#666666'), fontSize: 14.sp),
        selectedTextStyle: TextStyle(color: kAppTextColor, fontSize: 16.sp, fontWeight: FontWeight.bold),
//        delimiter: [
//          PickerDelimiter(
//              column: 5,
//              child: Container(
//                width: 16.0,
//                alignment: Alignment.center,
//                child: Text(':', style: TextStyle(fontWeight: FontWeight.bold)),
//                color: Colors.white,
//              ))
//        ],
        onConfirm: confirmCallback,
        onSelect: selectedCallback);
    showModalBottomSheet(
        context: context,
        backgroundColor: Colors.transparent,
        builder: (context) {
          return Material(
              color: kAppColor('#FFF7F6'),
              borderRadius: const BorderRadius.only(topLeft: Radius.circular(10), topRight: Radius.circular(10)),
              child: Container(
                padding: const EdgeInsets.only(top: 4),
                child: picker.makePicker(null, true),
              ));
        });
  }
}
